var shadowLayer = document.getElementById("shadowLayer");
var shadowLayer2 = document.getElementById("shadowLayer2");
var closeBtn = document.getElementsByClassName("closeBtn");
var closeBtn2 = document.getElementById("closeBtn2");

var setReport = document.getElementById("setReport");
var reportSetting = document.getElementById("reportSetting");
var addOption = document.getElementById("addOption");
var addOptionPage = document.getElementById("addOptionPage");
var checkDetailBtn = document.getElementsByClassName("checkDetailBtn");
var checkDetail = document.getElementById("checkDetail");
var addCredits = document.getElementById("addCredits");
var selectTypeBtn = document.getElementById("selectTypeBtn");
var selectType = document.getElementById("selectType");
var addNewTypeBtn = document.getElementById("addNewTypeBtn");
var addNewType = document.getElementById("addNewType");
var addGoodsCategoryBtn = document.getElementById("addGoodsCategoryBtn");
var addGoodsType= document.getElementById("addGoodsType");


// 返回数组下标函数
function getArrayIndex(arr, obj) {
 var i = arr.length;
 while (i--) {
	 if (arr[i] === obj) {
		 return i;
	 }
 }
 return -1;
}
function popupWindows(btn,contentBox,shadowLayer){
	if(btn){
		 btn.onclick = function show() {			
		 	shadowLayer.style.display = "webkit-flex";
		 	shadowLayer.style.display = "flex";			
		 	contentBox.style.display = "block";
		 }
	}
}
if(checkDetailBtn){
	for(var i = 0;i<checkDetailBtn.length;i++){
		checkDetailBtn[i].onclick = function (){
			shadowLayer.style.display = "webkit-flex";
			shadowLayer.style.display = "flex";			
			checkDetail.style.display = "block";
		}
	}
}
if(closeBtn){
	for(var i = 0;i<closeBtn.length;i++){
		closeBtn[i].onclick = function (){
			shadowLayer.style.display = "none";
			if(reportSetting){reportSetting.style.display = "none";}
			if(checkDetail){checkDetail.style.display = "none";}
			if(addOptionPage){addOptionPage.style.display = "none";}
					
		}
	}
}

// if(closeBtn){
// 	closeBtn.onclick = function close() {
// 		shadowLayer.style.display = "none";
// 		if(reportSetting){reportSetting.style.display = "none";}	
// 	}
// }
if(closeBtn2){
	closeBtn2.onclick = function close() {
		shadowLayer2.style.display = "none";
		if(addOptionPage){addOptionPage.style.display = "none";}
		
	}
}


 
popupWindows(setReport,reportSetting,shadowLayer);
popupWindows(selectTypeBtn,selectType,shadowLayer);
popupWindows(addOption,addOptionPage,shadowLayer2);
popupWindows(addCredits,addOptionPage,shadowLayer2);
popupWindows(addNewTypeBtn,addNewType,shadowLayer2);
popupWindows(addGoodsCategoryBtn,addGoodsType,shadowLayer2);


window.onclick = function close(e) {
	if (e.target == shadowLayer) {
		shadowLayer.style.display = "none";
		if(reportSetting){reportSetting.style.display = "none";}	
	}
	if(e.target == shadowLayer2){
		shadowLayer2.style.display = "none";
		if(addOptionPage){addOptionPage.style.display = "none";}
	}
	
}